package com.online.edu.eduservice.exception;

import com.online.edu.eduservice.entity.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description: 统一异常处理
 * @Author hlg
 * @Date 2020\3\2 0002
 * @Version V1.0
 **/
@ControllerAdvice
public class GlobalException {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R error(Exception e){
        e.printStackTrace();
        return R.error().message("出现异常");
    }
    /**
    *@MethodName: ArithmeticException
    *@Description: 特定异常处理
    *@Param: [e]
    *@Return: com.online.edu.eduservice.entity.R
    **/
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public R ArithmeticException(ArithmeticException e){
        e.printStackTrace();
        return R.error().message("出现异常");
    }
}
